function median(...nums) {
    return nums.sort()[Math.floor(nums.length / 2)];
};

const proxy = new Proxy(median, {
    construct(target, thisArgs, argumentsList) {
        for (const arg of argumentsList) {
            if (typeof arg !== 'number') {
                throw new Error('Non-number');
            };
        };

        return Reflect.apply(...arguments);
    }
});

console.log(proxy(1,4,7));   // 4
console.log(proxy(1, 4, '7'));